package com.yykj.user.center.server.controller.patient;

import com.yykj.common.vo.ResultVO;
import com.yykj.user.center.server.form.EvaluationForm;
import com.yykj.user.center.server.service.patient.EvaluationService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiImplicitParams;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import javax.validation.Valid;

/**
 * @author chenl
 * @version 1.0
 * @date 2021/10/30 22:05
 */
@Slf4j
@Api(tags = "评价相关接口")
@RestController
@RequestMapping("/api/evaluation")
@SuppressWarnings("unchecked")
public class EvaluationController {

    @Autowired
    private EvaluationService evaluationService;

    @PostMapping("/evaluate")
    @ApiOperation("患者评价医生")
    public ResultVO evaluate(@Valid @RequestBody EvaluationForm evaluationForm){
        return ResultVO.success(evaluationService.evaluate(evaluationForm));
    }

    @ApiImplicitParam(name = "doctorId", value = "医生Id", required = true, dataType = "String")
    @GetMapping("/showEvaluate")
    @ApiOperation("查看患者评价")
    public ResultVO showEvaluate(@RequestParam(name="doctorId" ,required = true) String doctorId){
        return ResultVO.success(evaluationService.showEvaluate(doctorId));
    }


    @ApiImplicitParams({
            @ApiImplicitParam(name = "current", value = "当前页", required = false, dataType = "Integer"),
            @ApiImplicitParam(name = "size", value = "每页显示的条数", required = false, dataType = "Integer"),
            @ApiImplicitParam(name = "startDate", value = "开始日期", required = false, dataType = "String"),
            @ApiImplicitParam(name = "endDate", value = "结束日期", required = false, dataType = "String"),
            @ApiImplicitParam(name = "patientName", value = "患者姓名", required = false, dataType = "String"),
            @ApiImplicitParam(name = "mobile", value = "手机号", required = false, dataType = "String"),
            @ApiImplicitParam(name = "orderNo", value = "订单编号", required = false, dataType = "String"),
            @ApiImplicitParam(name = "orderType", value = "订单类型：11、图文问诊 12、语音问诊 13、视频问诊 14、检查订单 15、检验订单", required = false, dataType = "Integer"),
            @ApiImplicitParam(name = "deptName", value = "科室", required = false, dataType = "String"),
            @ApiImplicitParam(name = "doctorName", value = "医生", required = false, dataType = "String"),
            @ApiImplicitParam(name = "hospitalId", value = "医院Id", required = false, dataType = "Integer"),
    })
    @ApiOperation(value = "评价列表", notes = "评价列表")
    @GetMapping("/list")
    public ResultVO list(@RequestParam(value = "current", required = false,defaultValue = "1") Integer current,
                                @RequestParam(value = "size", required = false,defaultValue = "1000") Integer size,
                                @RequestParam(value = "startDate", required = false) String startDate,
                                @RequestParam(value = "endDate", required = false) String endDate,
                                @RequestParam(value = "patientName", required = false) String patientName,
                                @RequestParam(value = "mobile", required = false) String mobile,
                                @RequestParam(value = "orderNo", required = false) String orderNo,
                                @RequestParam(value = "orderType", required = false) Integer orderType,
                                @RequestParam(value = "deptName", required = false) String deptName,
                                @RequestParam(value = "doctorName", required = false) String doctorName,
                                @RequestParam(value = "hospitalId", required = false) Integer hospitalId) {
        return ResultVO.success(evaluationService.list(current,size,startDate,endDate,patientName,mobile,orderNo,orderType,deptName, doctorName,hospitalId));
    }


    @GetMapping("/info")
    @ApiOperation("查看评价详情")
    public ResultVO info(@RequestParam(name="id" ,required = true) String id){
        return ResultVO.success(evaluationService.info(id));
    }
}
